<template>
  <div id="login">
    <div id="box">
      <div id="boxcon">
        <h1>知否知否后台管理系统</h1>
        <el-form
          :label-position="labelPosition"
          label-width="auto"
          :model="formLabelAlign"
          style="max-width: 300px"
        >
          <el-form-item label="用户名">
            <el-input v-model="formLabelAlign.username" :prefix-icon="Avatar" />
          </el-form-item>
          <el-form-item label="密码">
            <el-input
              v-model="formLabelAlign.password"
              show-password
              :prefix-icon="Lock"
            />
          </el-form-item>
        </el-form>
        <div>
          <!-- $router.push("/home") -->
          <el-button type="primary" @click="loginclicl()">登录</el-button>
          <el-button type="primary" plain>取消</el-button>
        </div>
      </div>
    </div>
  
  </div>
</template>


<script setup lang="ts">
import { reactive, ref } from "vue";
import type { FormProps } from "element-plus";
import { Avatar, Lock } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import { ElNotification } from "element-plus";
import axios from "axios";
const labelPosition = ref<FormProps["labelPosition"]>("right");
const formLabelAlign = reactive({
  username: "admin",
  password: "123456",
});
let router = useRouter();

// 登录接口
let loginclicl = async () => {
  let { data } = await axios.get("http://127.0.0.1:3000/getuser", {
    params: formLabelAlign,
  });
  if (data.code == 200) {
    ElNotification({
      title: "登录成功",
      message: "您的账号密码输入正确",
      type: "success",
    });
    router.push({ path: "home" });
  } else if (data.code == 201) {
    ElNotification({
      title: "登录失败",
      message: "您的账号输入错误",
      type: "error",
    });
  } else if (data.code == 202) {
    ElNotification({
      title: "登录失败",
      message: "您的密码输入错误",
      type: "error",
    });
  }
};
</script>
<style lang="less" scoped>
@property --direc {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
@keyframes rotate {
  to {
    --direc: 360deg;
  }
}
#login {
  height: 100vh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image:url('./222.jpg') ;
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
  position: relative;
  overflow: hidden;
  #box {
    #boxcon {
      margin: 0 auto;
      margin-top: 10px;
      width: 95%;
      height: 95%;
      border-radius: 5px;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: center;
    }
    animation: rotate 3s linear infinite;
    width: 25%;
    height: 40vh;

    background-image: linear-gradient(
      var(--direc),
      #5ddcff,
      #3c67e3 43%,
      #4e00c2
    );
  }
}
#particles{
      position: absolute;
      width: 100%;
      height: 100%;
      background-color: rgb(135, 183, 255);
      background-repeat: no-repeat;
      background-size: cover;
      background-position: 50% 50%;
}
</style>